package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/dialect"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/edge"
	"entgo.io/ent/schema/field"
	"entgo.io/ent/schema/mixin"
)

type CompanyExtend struct{}

// SysCompany holds the schema definition for the SysCompany entity.
type SysCompany struct {
	ent.Schema
}

func (SysCompany) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entsql.Annotation{Table: "sys_company"},
	}
}

// Fields of the SysCompany.
func (SysCompany) Fields() []ent.Field {
	return []ent.Field{
		field.String("name").SchemaType(map[string]string{
			dialect.MySQL: "varchar(100)", // Override MySQL.
		}).Comment("公司名称").Unique(),
		field.String("address").SchemaType(map[string]string{
			dialect.MySQL: "varchar(255)", // Override MySQL.
		}).Comment("公司地址").Optional(),
		field.String("tel").SchemaType(map[string]string{
			dialect.MySQL: "varchar(20)", // Override MySQL.
		}).Comment("公司电话").Optional(),
		field.String("email").SchemaType(map[string]string{
			dialect.MySQL: "varchar(50)", // Override MySQL.
		}).Comment("公司邮箱").Optional(),
		field.String("ak").SchemaType(map[string]string{
			dialect.MySQL: "varchar(16)", // Override MySQL.
		}).Comment("ak").Unique(),
		field.String("sk").SchemaType(map[string]string{
			dialect.MySQL: "varchar(32)", // Override MySQL.
		}).Comment("sk"),
		field.String("code").SchemaType(map[string]string{
			dialect.MySQL: "varchar(10)", // Override MySQL.
		}).Comment("公司编码").Unique(),
		field.String("service_name").SchemaType(map[string]string{
			dialect.MySQL: "varchar(50)", // Override MySQL.
		}).Comment("服务发现名称 用于多租户").Optional(),
		field.Time("delete_time").SchemaType(map[string]string{
			dialect.MySQL: "datetime", // Override MySQL.
		}).Optional().Comment("删除时间"),
	}
}

// Edges of the SysCompany.
func (SysCompany) Edges() []ent.Edge {
	return []ent.Edge{
		edge.To("users", SysUser.Type),
	}
}

// Mixin of the SysCompany.
func (SysCompany) Mixin() []ent.Mixin {
	return []ent.Mixin{
		mixin.Time{},
	}
}
